package com.example.test_event_and_callback.infras.async;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;

public class DemanderProcessorDirectCall extends AsyncDemanderProcessor<Consumer<Object>>{

    public DemanderProcessorDirectCall(Class<?> demanderClass) {
        if (demanderClass.getSuperclass().equals(Demander.class)){
            return;
        }
        throw new RuntimeException("使用直接调用策略的类" + demanderClass.getName() + " ，必须继承AsyncDto类");
    }

    @Override
    Consumer<Object> exchangeMethod(Field field, Method method) {
        return null;
    }

    @Override
    <T extends Demander> void setParam(T dto, String paramName, Object param) {
        dto.getMappedFunction().get(paramName).accept(param);
    }
}
